//
//  UpdatePasswordController.m
//  Job
//
//  Created by 欧松 on 2018/8/26.
//  Copyright © 2018年 桑赐相. All rights reserved.
//

#import "UpdatePasswordController.h"
#import "LoginViewController.h"

@interface UpdatePasswordController ()

@property (weak, nonatomic) IBOutlet UITextField *oldPassword;

@property (weak, nonatomic) IBOutlet UITextField *refreshPassword;

@property (weak, nonatomic) IBOutlet UIButton *updateBtn;


@end

@implementation UpdatePasswordController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"修改密码";
    [self.updateBtn setLayerWithRadius:5 color:ClearColor width:0];
    
    
    
}




- (IBAction)confirmChangePassword:(UIButton *)sender {
    [self.view endEditing:YES];
    NSString *old = self.oldPassword.text;
    NSString *new = self.refreshPassword.text;
    
    if (old.length <= 0) {
        [iToast showCenter:@"旧密码不能为空!"];
        return;
    }
    if (new.length <= 0) {
        [iToast showCenter:@"新密码不能为空!"];
        return;
    }
    
    if (new.length < 6) {
        [iToast showCenter:@"密码不能少于6位"];
        return;
    }
    
    
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    dict[@"oldPwd"] = old;
    dict[@"newPwd"] = new;
    
    [HTTPTools POST:updatePasswordUrl parameters:dict callback:^(id result, NSString *msg,NSError *error) {
        if (!error) {
            if (!msg) {
                [UserModel removeUserInfo];
                [MBProgressHUD showSuccess:@"密码修改成功"];
                [self.navigationController popToRootViewControllerAnimated:YES];
            }else{
                [MBProgressHUD showError:msg];
            }
        }
    }];
}

@end



